home *** CD-ROM | disk | FTP | other *** search
/ Macintosh Technology Seed 1996 September / Macintosh Technology Seed (September 1996) (CDRM1437020).ISO / pc / qd3d15d6 / 15d6_sdk.exe / QD3D Win32 1.5d6 / Interfaces / QD3DCamera.h < prev    next >
C/C++ Source or Header  |  1996-08-21  |  11KB  |  351 lines

  1. /******************************************************************************
  2.  **                                                                             **
  3.  **     Module:        QD3DCamera.h                                             **
  4.  **                                                                          **
  5.  **                                                                          **
  6.  **     Purpose:     Generic camera routines                                      **
  7.  **                                                                          **
  8.  **                                                                          **
  9.  **                                                                          **
  10.  **     Copyright (C) 1991-1996 Apple Computer, Inc. All rights reserved.     **    
  11.  **                                                                          **
  12.  **                                                                          **
  13.  *****************************************************************************/
  14. #ifndef QD3DCamera_h
  15. #define QD3DCamera_h
  16.  
  17. #if defined(PRAGMA_ONCE) && PRAGMA_ONCE
  18.     #pragma once
  19. #endif  /*  PRAGMA_ONCE  */
  20.  
  21. #if defined(THINK_C) || defined(__SC__)
  22.     #pragma options(!pack_enums, !align_arrays)
  23.     #pragma SC options align=power
  24. #elif defined(__MWERKS__)
  25.     #pragma enumsalwaysint on
  26.     #pragma align_array_members off
  27.     #pragma options align=native
  28. #elif defined(__PPCC__)
  29.     #pragma options align=power
  30. #elif defined(__xlc) || defined(__xlC) || defined(__xlC__) || defined(__XLC121__)
  31.     #pragma options enum=int
  32. #endif
  33.  
  34. #ifdef __cplusplus
  35. extern "C" {
  36. #endif    /* __cplusplus */
  37.  
  38.  
  39. /******************************************************************************
  40.  **                                                                             **
  41.  **                            Data Structure Definitions                         **
  42.  **                                                                             **
  43.  *****************************************************************************/
  44. /*
  45.  *  The placement of the camera.
  46.  */
  47. typedef struct TQ3CameraPlacement{
  48.     TQ3Point3D        cameraLocation;        /*  Location point of the camera     */
  49.     TQ3Point3D        pointOfInterest;    /*  Point of interest                 */
  50.     TQ3Vector3D        upVector;            /*  "up" vector                     */
  51. } TQ3CameraPlacement;
  52.  
  53.  
  54. /*
  55.  *  The range of the camera.
  56.  */
  57. typedef struct TQ3CameraRange {
  58.     float    hither;        /*  Hither plane, measured from "from" towards "to"    */
  59.     float    yon;        /*  Yon  plane, measured from "from" towards "to"     */
  60. } TQ3CameraRange;
  61.  
  62.  
  63. /*
  64.  *  Viewport specification.  Origin is (-1, 1), and corresponds to the 
  65.  *  upper left-hand corner; width and height maximum is (2.0, 2.0),
  66.  *  corresponding to the lower left-hand corner of the window.  The
  67.  *  TQ3Viewport specifies a part of the viewPlane that gets displayed 
  68.  *    on the window that is to be drawn.
  69.  *  Normally, it is set with an origin of (-1.0, 1.0), and a width and
  70.  *  height of both 2.0, specifying that the entire window is to be
  71.  *  drawn.  If, for example, an exposure event of the window exposed
  72.  *  the right half of the window, you would set the origin to (0, 1),
  73.  *  and the width and height to (1.0) and (2.0), respectively.
  74.  *
  75.  */
  76. typedef struct TQ3CameraViewPort {
  77.     TQ3Point2D        origin;
  78.     float            width;
  79.     float            height;
  80. } TQ3CameraViewPort;
  81.  
  82.  
  83. typedef struct TQ3CameraData {
  84.     TQ3CameraPlacement    placement;
  85.     TQ3CameraRange        range;
  86.     TQ3CameraViewPort    viewPort;
  87. } TQ3CameraData;
  88.  
  89.  
  90. /*
  91.  *  An orthographic camera.
  92.  *
  93.  *  The lens characteristics are set with the dimensions of a
  94.  *  rectangular viewPort in the frame of the camera.
  95.  */
  96. typedef struct TQ3OrthographicCameraData {
  97.     TQ3CameraData        cameraData;
  98.     float                left;
  99.     float                top;
  100.     float                right;
  101.     float                bottom;
  102. } TQ3OrthographicCameraData;
  103.  
  104. /*
  105.  *  A perspective camera specified in terms of an arbitrary view plane.
  106.  *
  107.  *  This is most useful when setting the camera to look at a particular
  108.  *  object.  The viewPlane is set to distance from the camera to the object.
  109.  *  The halfWidth is set to half the width of the cross section of the object,
  110.  *  and the halfHeight equal to the halfWidth divided by the aspect ratio
  111.  *  of the viewPort.
  112.  * 
  113.  *  This is the only perspective camera with specifications for off-axis
  114.  *  viewing, which is desirable for scrolling.
  115.  */
  116. typedef struct TQ3ViewPlaneCameraData {
  117.     TQ3CameraData        cameraData;
  118.     float                viewPlane;
  119.     float                halfWidthAtViewPlane;
  120.     float                halfHeightAtViewPlane;
  121.     float                centerXOnViewPlane;
  122.     float                centerYOnViewPlane;
  123. } TQ3ViewPlaneCameraData;
  124.  
  125. /*
  126.  *    A view angle aspect camera is a perspective camera specified in 
  127.  *    terms of the minimum view angle and the aspect ratio of X to Y.
  128.  *
  129.  */
  130. typedef struct TQ3ViewAngleAspectCameraData {
  131.     TQ3CameraData        cameraData;
  132.     float                fov;
  133.     float                aspectRatioXToY;
  134. } TQ3ViewAngleAspectCameraData;
  135.  
  136.  
  137. /******************************************************************************
  138.  **                                                                             **
  139.  **                            Generic Camera routines                             **
  140.  **                                                                             **
  141.  *****************************************************************************/
  142.  
  143.  
  144. QD3D_EXPORT TQ3ObjectType Q3Camera_GetType(
  145.     TQ3CameraObject                camera);
  146.  
  147. QD3D_EXPORT TQ3Status Q3Camera_SetData(
  148.     TQ3CameraObject                camera,
  149.     const TQ3CameraData            *cameraData);
  150.  
  151. QD3D_EXPORT TQ3Status Q3Camera_GetData(
  152.     TQ3CameraObject                camera,
  153.     TQ3CameraData                *cameraData);
  154.     
  155. QD3D_EXPORT TQ3Status Q3Camera_SetPlacement(
  156.     TQ3CameraObject                camera,
  157.     const TQ3CameraPlacement    *placement);
  158.     
  159. QD3D_EXPORT TQ3Status Q3Camera_GetPlacement(
  160.     TQ3CameraObject                camera,
  161.     TQ3CameraPlacement            *placement);
  162.     
  163. QD3D_EXPORT TQ3Status Q3Camera_SetRange(
  164.     TQ3CameraObject                camera,
  165.     const TQ3CameraRange        *range);
  166.  
  167. QD3D_EXPORT TQ3Status Q3Camera_GetRange(
  168.     TQ3CameraObject                camera,
  169.     TQ3CameraRange                *range);
  170.  
  171. QD3D_EXPORT TQ3Status Q3Camera_SetViewPort(
  172.     TQ3CameraObject                camera,
  173.     const TQ3CameraViewPort        *viewPort);
  174.  
  175. QD3D_EXPORT TQ3Status Q3Camera_GetViewPort(
  176.     TQ3CameraObject                camera,
  177.     TQ3CameraViewPort            *viewPort);
  178.  
  179. QD3D_EXPORT TQ3Status Q3Camera_GetWorldToView( 
  180.     TQ3CameraObject                camera,
  181.     TQ3Matrix4x4                *worldToView);
  182.  
  183. QD3D_EXPORT TQ3Status Q3Camera_GetWorldToFrustum( 
  184.     TQ3CameraObject                camera,
  185.     TQ3Matrix4x4                *worldToFrustum);
  186.  
  187. QD3D_EXPORT TQ3Status Q3Camera_GetViewToFrustum(
  188.     TQ3CameraObject                camera,
  189.     TQ3Matrix4x4                *viewToFrustum);
  190.  
  191.  
  192. /******************************************************************************
  193.  **                                                                             **
  194.  **                            Specific Camera Routines                          **
  195.  **                                                                             **
  196.  *****************************************************************************/
  197.  
  198. /******************************************************************************
  199.  **                                                                             **
  200.  **                            Orthographic Camera                                  **
  201.  **                                                                             **
  202.  *****************************************************************************/
  203.  
  204. QD3D_EXPORT TQ3CameraObject Q3OrthographicCamera_New(
  205.     const TQ3OrthographicCameraData    *orthographicData);
  206.  
  207. QD3D_EXPORT TQ3Status Q3OrthographicCamera_GetData(
  208.     TQ3CameraObject                    camera,
  209.     TQ3OrthographicCameraData        *cameraData);
  210.  
  211. QD3D_EXPORT TQ3Status Q3OrthographicCamera_SetData(
  212.     TQ3CameraObject                    camera,
  213.     const TQ3OrthographicCameraData    *cameraData);
  214.  
  215. QD3D_EXPORT TQ3Status Q3OrthographicCamera_SetLeft(
  216.     TQ3CameraObject                    camera,
  217.     float                            left);
  218.     
  219. QD3D_EXPORT TQ3Status Q3OrthographicCamera_GetLeft(
  220.     TQ3CameraObject                    camera,
  221.     float                            *left);
  222.  
  223. QD3D_EXPORT TQ3Status Q3OrthographicCamera_SetTop(
  224.     TQ3CameraObject                    camera,
  225.     float                            top);
  226.     
  227. QD3D_EXPORT TQ3Status Q3OrthographicCamera_GetTop(
  228.     TQ3CameraObject                    camera,
  229.     float                            *top);
  230.  
  231. QD3D_EXPORT TQ3Status Q3OrthographicCamera_SetRight(
  232.     TQ3CameraObject                    camera,
  233.     float                            right);
  234.     
  235. QD3D_EXPORT TQ3Status Q3OrthographicCamera_GetRight(
  236.     TQ3CameraObject                    camera,
  237.     float                            *right);
  238.  
  239. QD3D_EXPORT TQ3Status Q3OrthographicCamera_SetBottom(
  240.     TQ3CameraObject                    camera,
  241.     float                            bottom);
  242.     
  243. QD3D_EXPORT TQ3Status Q3OrthographicCamera_GetBottom(
  244.     TQ3CameraObject                    camera,
  245.     float                            *bottom);
  246.  
  247.  
  248. /******************************************************************************
  249.  **                                                                             **
  250.  **                            ViewPlane Camera                                  **
  251.  **                                                                             **
  252.  *****************************************************************************/
  253.  
  254. QD3D_EXPORT TQ3CameraObject Q3ViewPlaneCamera_New(
  255.     const TQ3ViewPlaneCameraData    *cameraData);
  256.     
  257. QD3D_EXPORT TQ3Status Q3ViewPlaneCamera_GetData(
  258.     TQ3CameraObject                    camera,
  259.     TQ3ViewPlaneCameraData            *cameraData);
  260.  
  261. QD3D_EXPORT TQ3Status Q3ViewPlaneCamera_SetData(
  262.     TQ3CameraObject                    camera,
  263.     const TQ3ViewPlaneCameraData    *cameraData);
  264.  
  265. QD3D_EXPORT TQ3Status Q3ViewPlaneCamera_SetViewPlane(
  266.     TQ3CameraObject                    camera,
  267.     float                            viewPlane);
  268.     
  269. QD3D_EXPORT TQ3Status Q3ViewPlaneCamera_GetViewPlane(
  270.     TQ3CameraObject                    camera,
  271.     float                            *viewPlane);
  272.  
  273. QD3D_EXPORT TQ3Status Q3ViewPlaneCamera_SetHalfWidth(
  274.     TQ3CameraObject                    camera,
  275.     float                            halfWidthAtViewPlane);
  276.  
  277. QD3D_EXPORT TQ3Status Q3ViewPlaneCamera_GetHalfWidth(
  278.     TQ3CameraObject                    camera,
  279.     float                            *halfWidthAtViewPlane);
  280.  
  281. QD3D_EXPORT TQ3Status Q3ViewPlaneCamera_SetHalfHeight(
  282.     TQ3CameraObject                    camera,
  283.     float                            halfHeightAtViewPlane);
  284.  
  285. QD3D_EXPORT TQ3Status Q3ViewPlaneCamera_GetHalfHeight(
  286.     TQ3CameraObject                    camera,
  287.     float                            *halfHeightAtViewPlane);
  288.     
  289. QD3D_EXPORT TQ3Status Q3ViewPlaneCamera_SetCenterX(
  290.     TQ3CameraObject                    camera,
  291.     float                            centerXOnViewPlane);
  292.     
  293. QD3D_EXPORT TQ3Status Q3ViewPlaneCamera_GetCenterX(
  294.     TQ3CameraObject                    camera,
  295.     float                            *centerXOnViewPlane);
  296.     
  297. QD3D_EXPORT TQ3Status Q3ViewPlaneCamera_SetCenterY(
  298.     TQ3CameraObject                    camera,
  299.     float                            centerYOnViewPlane);
  300.     
  301. QD3D_EXPORT TQ3Status Q3ViewPlaneCamera_GetCenterY(
  302.     TQ3CameraObject                    camera,
  303.     float                            *centerYOnViewPlane);
  304.  
  305.  
  306. /******************************************************************************
  307.  **                                                                             **
  308.  **                            View Angle Aspect Camera                          **
  309.  **                                                                             **
  310.  *****************************************************************************/
  311.  
  312. QD3D_EXPORT TQ3CameraObject Q3ViewAngleAspectCamera_New(
  313.     const TQ3ViewAngleAspectCameraData    *cameraData);
  314.  
  315. QD3D_EXPORT TQ3Status Q3ViewAngleAspectCamera_SetData(
  316.     TQ3CameraObject                        camera,
  317.     const TQ3ViewAngleAspectCameraData    *cameraData);
  318.     
  319. QD3D_EXPORT TQ3Status Q3ViewAngleAspectCamera_GetData(
  320.     TQ3CameraObject                        camera,
  321.     TQ3ViewAngleAspectCameraData        *cameraData);
  322.  
  323. QD3D_EXPORT TQ3Status Q3ViewAngleAspectCamera_SetFOV(
  324.     TQ3CameraObject                        camera,
  325.     float                                fov);
  326.  
  327. QD3D_EXPORT TQ3Status Q3ViewAngleAspectCamera_GetFOV(
  328.     TQ3CameraObject                        camera,
  329.     float                                *fov);
  330.  
  331. QD3D_EXPORT TQ3Status Q3ViewAngleAspectCamera_SetAspectRatio(
  332.     TQ3CameraObject                        camera,
  333.     float                                aspectRatioXToY);
  334.     
  335. QD3D_EXPORT TQ3Status Q3ViewAngleAspectCamera_GetAspectRatio(
  336.     TQ3CameraObject                        camera,
  337.     float                                *aspectRatioXToY);
  338.  
  339.  
  340. #ifdef __cplusplus
  341. }
  342. #endif    /* __cplusplus */
  343.  
  344. #if defined(__MWERKS__)
  345.     #pragma enumsalwaysint reset
  346. #elif defined(__xlc) || defined(__xlC) || defined(__xlC__) || defined(__XLC121__)
  347.     #pragma options enum=reset
  348. #endif
  349.  
  350. #endif  /*  QD3DCamera_h  */
  351.